from aiogram_dialog import Dialog, Window
from aiogram_dialog.widgets.input import TextInput
from aiogram_dialog.widgets.kbd import Back, Button, Cancel, Group

from src.presentation.tg_bot.dialogs.widgets import LocaleText
from src.presentation.tg_bot.states import IpChangePeriodSG

from .handlers import select_custom_period, set_ip_change_period

rotation_period_window = Window(
    LocaleText("select-rotation-period"),
    Group(
        Button(LocaleText("five_minutes"), id="5", on_click=set_ip_change_period),
        Button(LocaleText("ten_minutes"), id="10", on_click=set_ip_change_period),
        Button(
            LocaleText("twenty_minutes"),
            id="20",
            on_click=set_ip_change_period,
        ),
        Button(LocaleText("one_hour"), id="60", on_click=set_ip_change_period),
        Button(LocaleText("by_link"), id="0", on_click=set_ip_change_period),
        Button(
            LocaleText("custom-option"),
            id="your_option",
            on_click=select_custom_period,
        ),
        width=2,
    ),
    Cancel(LocaleText("back-btn")),
    state=IpChangePeriodSG.select_ip_change_period,
)

custom_rotation_period_window = Window(
    LocaleText("select-ip-address"),
    TextInput("customperiodinp", int, on_success=set_ip_change_period),
    Back(LocaleText("back-btn")),
    Cancel(LocaleText("cancel-btn")),
    state=IpChangePeriodSG.select_custom_period,
)

rotation_period_dialog = Dialog(rotation_period_window, custom_rotation_period_window)
